package com.avetti.commerce.inventory.domainmodel;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.avetti.simplemerce.domainmodel.OrderItem;

/**
 * Domain model for table "invhist"
 * @author wei sun
 *
 */
@SuppressWarnings("serial")
public class InventoryHistory implements Serializable
{
    public static enum Status { 
        /** this record is active,nither in {@link Status#ORDER_PLACED} nor {@link Status#BEEN_ROLLBACK} */
        ACTIVE { public Integer statusValue(){ return 1; } },
        
        /** the relatived order was placed */
        ORDER_PLACED { public Integer statusValue(){ return 2; } },
        
        /** this record has been putback */
        BEEN_ROLLBACK { public Integer statusValue(){ return 3; } };
        
        abstract public Integer statusValue();    
    }
    
    /** primary key */
    private Long invhistid;
    
    /** vendor id*/
    private String vid;
    
    /** the primary key in table "orderdata" */
    private Long orderdataid;
    
    /** the primary key in table "inventory" */
    private Long inventoryid;
    
    /** inventory code */
    private String code;
    
    /** customer ordered qty */
    private Integer qty;
    
    /** the qty in stock right now(after decrement) */
    private Integer qtyinstock;
    
    /** The inventory.nextshipqty before decrement */
    private Integer priornextshipqty;
    
    /** first ship quantity */
    private Integer ship1qty;
    
    /** first ship date */
    private Date ship1date;
    
    /** second ship quantity */
    private Integer ship2qty;
    
    /** second ship date */
    private Date ship2date;
    
    /** ship comment from customer */
    private String shipnote;
    
    /** the days of drop ship */
    private Integer daystodeliver;
    
    /** the delivery option customer chose */
    private Integer deliveryoption;
    
    /** clientid or adminid or session id or cookieid to track who do the operation */
    private String operatorid;
    
    /** the operation note */
    private String operationnote;
    
    /**  indicate if this record has been put back */
    private Integer status=Status.ACTIVE.statusValue();
    
    /** time stamp of this record insert or update */
    private Date timestamp;
    
    private OrderItem orderItem;

	/**
     * @return Returns the code.
     */
    public String getCode()
    {
        return code;
    }

    /**
     * @param code The code to set.
     */
    public void setCode(String code)
    {
        this.code = code;
    }

    /**
     * @return Returns the daystodeliver.
     */
    public Integer getDaystodeliver()
    {
        return daystodeliver;
    }

    /**
     * @param daystodeliver The daystodeliver to set.
     */
    public void setDaystodeliver(Integer daystodeliver)
    {
        this.daystodeliver = daystodeliver;
    }

    /**
     * @return Returns the deliveryoption.
     */
    public Integer getDeliveryoption()
    {
        return deliveryoption;
    }

    /**
     * @param deliveryoption The deliveryoption to set.
     */
    public void setDeliveryoption(Integer deliveryoption)
    {
        this.deliveryoption = deliveryoption;
    }

    /**
     * @return Returns the inventoryid.
     */
    public Long getInventoryid()
    {
        return inventoryid;
    }

    /**
     * @param inventoryid The inventoryid to set.
     */
    public void setInventoryid(Long inventoryid)
    {
        this.inventoryid = inventoryid;
    }

    /**
     * @return Returns the invhistid.
     */
    public Long getInvhistid()
    {
        return invhistid;
    }

    /**
     * @param invhistid The invhistid to set.
     */
    public void setInvhistid(Long invhistid)
    {
        this.invhistid = invhistid;
    }

    /**
     * @return Returns the operationnote.
     */
    public String getOperationnote()
    {
        return operationnote;
    }

    /**
     * @param operationnote The operationnote to set.
     */
    public void setOperationnote(String operationnote)
    {
        this.operationnote = operationnote;
    }

    /**
     * @return Returns the operatorid.
     */
    public String getOperatorid()
    {
        return operatorid;
    }

    /**
     * @param operatorid The operatorid to set.
     */
    public void setOperatorid(String operatorid)
    {
        this.operatorid = operatorid;
    }

    /**
     * @return Returns the orderdataid.
     */
    public Long getOrderdataid()
    {
        return orderdataid;
    }

    /**
     * @param orderdataid The orderdataid to set.
     */
    public void setOrderdataid(Long orderdataid)
    {
        this.orderdataid = orderdataid;
    }

    /**
     * @return Returns the qty.
     */
    public Integer getQty()
    {
        return qty;
    }

    /**
     * @param qty The qty to set.
     */
    public void setQty(Integer qty)
    {
        this.qty = qty;
    }

    /**
     * @return Returns the qtyinstock.
     */
    public Integer getQtyinstock()
    {
        return qtyinstock;
    }

    /**
     * @param qtyinstock The qtyinstock to set.
     */
    public void setQtyinstock(Integer qtyinstock)
    {
        this.qtyinstock = qtyinstock;
    }

    /**
     * @return Returns the ship1date.
     */
    public Date getShip1date()
    {
        return ship1date;
    }

    /**
     * @param ship1date The ship1date to set.
     */
    public void setShip1date(Date ship1date)
    {
        this.ship1date = ship1date;
    }

    /**
     * @return Returns the ship1qty.
     */
    public Integer getShip1qty()
    {
        return ship1qty;
    }

    /**
     * @param ship1qty The ship1qty to set.
     */
    public void setShip1qty(Integer ship1qty)
    {
        this.ship1qty = ship1qty;
    }

    /**
     * @return Returns the ship2date.
     */
    public Date getShip2date()
    {
        return ship2date;
    }

    /**
     * @param ship2date The ship2date to set.
     */
    public void setShip2date(Date ship2date)
    {
        this.ship2date = ship2date;
    }

    /**
     * @return Returns the ship2qty.
     */
    public Integer getShip2qty()
    {
        return ship2qty;
    }

    /**
     * @param ship2qty The ship2qty to set.
     */
    public void setShip2qty(Integer ship2qty)
    {
        this.ship2qty = ship2qty;
    }

    /**
     * @return Returns the shipnote.
     */
    public String getShipnote()
    {
        return shipnote;
    }

    /**
     * @param shipnote The shipnote to set.
     */
    public void setShipnote(String shipnote)
    {
        this.shipnote = shipnote;
    }

    /**
     * @return Returns the timestamp.
     */
    public Date getTimestamp()
    {
        return timestamp;
    }

    /**
     * @param timestamp The timestamp to set.
     */
    public void setTimestamp(Date timestamp)
    {
        this.timestamp = timestamp;
    }

    /**
     * @return Returns the vid.
     */
    public String getVid()
    {
        return vid;
    }

    /**
     * @param vid The vid to set.
     */
    public void setVid(String vid)
    {
        this.vid = vid;
    }

    /**
     * @return Returns the active.
     */
    public Integer getStatus()
    {
        return status;
    }

    /**
     * @param active The active to set.
     */
    public void setStatus(Integer active)
    {
        this.status = active;
    }
    
    public boolean equals(Object other) 
    {
        if ( !(other instanceof InventoryHistory) ) 
            return false;
        InventoryHistory castOther = (InventoryHistory) other;
        return new EqualsBuilder()
            .append(this.getInvhistid(), castOther.getInvhistid())
            .isEquals();
    }

    public int hashCode() 
    {
        return new HashCodeBuilder()
            .append(getInvhistid())
            .toHashCode();
    }

    /**
     * @return Returns the priornextshipqty.
     */
    public Integer getPriornextshipqty()
    {
        return priornextshipqty;
    }

    /**
     * @param priornextshipqty The priornextshipqty to set.
     */
    public void setPriornextshipqty(Integer priornextshipqty)
    {
        this.priornextshipqty = priornextshipqty;
    }

	/**
	 * @return the orderItem
	 */
	public OrderItem getOrderItem() {
		return orderItem;
	}

	/**
	 * @param orderItem the orderItem to set
	 */
	public void setOrderItem(OrderItem orderItem) {
		this.orderItem = orderItem;
	}
}
